/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 5e3;

char str[maxn + 1];

int main() {
  int n;
  cin >> n >> (str + 1);
  for (int i = 1; i < n; ++i) {
    int j;
    for (j = 1; j + i <= n; ++j) {
      if (str[j] == str[j + i]) {
        break;
      }
    }
    cout << j - 1 << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("B - Longest Uncommon Prefix.in", "r", stdin);
  freopen("B - Longest Uncommon Prefix.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
